package com.jswlw.controller.distributor;

import com.jswlw.entity.biz.OrderInfo;
import com.jswlw.service.biz.OrderInfoService;
import com.jswlw.web.manager.SessionDistributorManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.Objects;

/**
 * @author 吴维斌 E-mail:wuweibin0817@163.com
 * @version 创建时间：${date} ${time}
 */
@Controller
@RequestMapping("/distributor/order")
public class DistributorOrderController {

    @Autowired
    OrderInfoService orderInfoService;

    @RequestMapping("index")
    public ModelAndView index(@RequestParam(value = "status", required = false) Integer status) {
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/distributor/order/index");
        modelAndView.addObject("status", status);
        OrderInfo filter = new OrderInfo();
        if (Objects.nonNull(status)) {
            filter.setPayStatus(status);
        }
        filter.setDistributorIds(SessionDistributorManager.getCurrentUser().getChildrenIds());
        modelAndView.addObject("orderList", orderInfoService.queryList(filter));
        return modelAndView;
    }
}
